package com.ssy.lingxi.after.sale.repository;

import com.ssy.lingxi.after.sale.entity.InnerWorkflowRecordDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 售后内部工作流记录
 * @author 伍将
 * @date 2020/9/2
 * @version 2.0.0
 */
public interface InnerWorkflowRecordRepository extends JpaRepository<InnerWorkflowRecordDO, Long>, JpaSpecificationExecutor<InnerWorkflowRecordDO> {


    /**
     * 查询操作用户的内部流转记录并按操作时间顺序排序
     * @author 伍将
     * @date 2020/12/26
     * @param afterSaleId:
     * @param afterSaleType:
     * @param memberId:
     * @param roleId:
     * @return:
     **/
    @Query(value = "select * from as_inner_Workflow_record where after_sale_id=:afterSaleId and after_sale_type=:afterSaleType " +
            "and member_id=:memberId and role_id=:roleId Order By operate_time Asc", nativeQuery = true)
    List<InnerWorkflowRecordDO> findAllRecord(Long afterSaleId, Integer afterSaleType, Long memberId, Long roleId);
}
